package com.axcbd.demo.dto.response;

import lombok.Data;

@Data
public class ApiResponse<T> {
    private boolean success; // 操作是否成功
    private String message; // 操作消息（成功或失败的描述）
    private T data; // 操作结果数据

    public ApiResponse(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }


    // 构造成功响应的方法
    public ApiResponse(T data) {
        this.success = true;
        this.message = "操作成功";
        this.data = data;
    }

    public ApiResponse(String message, T data) {
        this.success = true;
        this.message = message;
        this.data = data;
    }

    // 构造失败响应的方法
    public ApiResponse(String message) {
        this.success = false;
        this.message = message;
        this.data = null;
    }
}
